package com.hqyj.javaGraduation.hotel.controller;

import com.hqyj.javaGraduation.hotel.pojo.UserTableInfo;
import com.hqyj.javaGraduation.hotel.service.UserTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
@RequestMapping("/api")
public class UserTableController {

    @Autowired
    private UserTableService userTableService;

    /**
     * 127.0.0.1:8080/api/userReserveTables   ---   post
     * {"utId":0,"userId":1,"tableId":4,"utReserveDate":"2021-09-26 14:45:22","utPhone":"123456"}
     */
    // 客户预定座位
    @PostMapping(value = "/userReserveTables",consumes = "application/json")
    public HashMap<String, Object> insertUserReserveTable(@RequestBody UserTableInfo userTableInfo){
        return userTableService.insertUserReserveTable(userTableInfo);
    }

    /**
     * 127.0.0.1:8080/api/userReserveTable   ---   delete
     * {"utId":1,"userId":1,"tableId":4,"utReserveDate":null,"utPhone":"123456"}
     */
    // 取消座位预定
    @DeleteMapping(value = "/userReserveTable",consumes = "application/json")
    public HashMap<String, Object> deleteUserReserveTableByUserTableInfo(@RequestBody UserTableInfo userTableInfo) {
        return userTableService.deleteUserReserveTableByUserTableInfo(userTableInfo);
    }

    /**
     * 127.0.0.1:8080/api/userReserveTable   ---   put
     * {"utId":1,"userId":1,"tableId":4,"utReserveDate":"2021-09-28 08:50:22","utPhone":"123456","utState":"已完成"}
     */
    // 客户在预定时间内到达
    @PutMapping(value = "/userReserveTable",consumes = "application/json")
    public HashMap<String, Object> updateUserReserveTable(@RequestBody UserTableInfo userTableInfo){
        return userTableService.updateUserReserveTable(userTableInfo);
    }
}
